using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO;
using Microsoft.MultiPoint.MultiPointCommonTypes;
using Microsoft.MultiPoint.MultiPointSDK;
using Microsoft.MultiPoint.MultiPointMouseFilter;
using Microsoft.MultiPoint.MultiPointControls;


namespace MultipointTest
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : System.Windows.Window
    {
        public Window1()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(Test_Loaded);
        }

        void Test_Loaded(object sender, RoutedEventArgs args)
        {
            try
            {
                InitialMultipointSDK();
                InitialCheck();
                this.MultiPointTestButton.MultiPointClick += new RoutedEventHandler(MultiPointClick_Handler);
            }
            catch (MultiPointException e)
            {
                Console.WriteLine("Error: " + e.Message);
            }
        }

        void MultiPointClick_Handler(object sender, RoutedEventArgs args)
        {
            MultiPointMouseEventArgs multipointArgs = (MultiPointMouseEventArgs)args;
            string  id = multipointArgs.DeviceInfo.DeviceID;
            this.MultiPointTestTextBox.Text = id;
        }

        private void InitialMultipointSDK()
        {
            App.MultiPointObject.SystemCursorPosition = new Point((int)this.Left + 10, (int)this.Top + 10);
            App.MultiPointObject.RegisterMouseDevice();
            MultiPointSDK.HideSystemCursor();
            App.MultiPointObject.CurrentWindow = this;
            App.MultiPointObject.DrawDevice();
        }

        private void InitialCheck()
        {
            if (App.MultiPointObject.MouseDeviceList.Count == 1)
            {
                Console.WriteLine("Two mice are required to watch the features of MS Multipoint");
                return;
            }
            ((MultiPointMouseDevice)((DeviceInfo)(App.MultiPointObject.MouseDeviceList[0])).DeviceVisual).CursorColor = System.Windows.Media.Colors.Green;
            ((MultiPointMouseDevice)((DeviceInfo)(App.MultiPointObject.MouseDeviceList[0])).DeviceVisual).CursorColor = System.Windows.Media.Colors.Gold;
        }
    }
}